package com.dts.listener;

import jakarta.servlet.http.HttpSession;
import jakarta.servlet.http.HttpSessionActivationListener;
import jakarta.servlet.http.HttpSessionEvent;

import java.io.Serial;
import java.io.Serializable;

public class Consumer   implements HttpSessionActivationListener, Serializable {
    @Serial
    private static final long serialVersionUID = 5658426586996600553L;
    private String userId;
    private String realName;
    @Override
    public void sessionWillPassivate(HttpSessionEvent event) {
        HttpSession session = event.getSession();
        Consumer con = (Consumer) session.getAttribute("consumer");
        System.out.println(con.getUserId() + " and session will passivate, session's id: " + event.getSession().getId());
    }
    @Override
    public void sessionDidActivate(HttpSessionEvent event) {
        HttpSession session = event.getSession();
        Consumer con = (Consumer) session.getAttribute("consumer");
        System.out.println(con.getUserId() + " and session did activate, session's id: " + event.getSession().getId());
    }
//次数省略getter和setter方法

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }
}
